<%@page contentType="text/html;charset=UTF-8"%>
<%@page pageEncoding="UTF-8"%>
<%@ include file="/pub/includ.jsp"%>
<html>
	<head>
		<script type="text/javascript">
		
			$(function(){
				//加载两个要使用json分页的组�?
		        loadGird("frm", 1);
			})
				
			var callback_frm = function(rows, frm) {
		       $.each(rows, function(i, n){
		    	   var row = $("#"+frm+" .template").clone().removeClass("template");
		   			       var keyValue = n.id;
			       row.find(".klId").attr("value",n.id);
			   	
			       row.find(".klplaceholderid").text(n.placeholderid);
			   	
			       row.find(".klchannelid").text(n.channelid);
			   	
			       row.find(".klportletid").text(n.portletid);
			   	
			       row.find(".kllayoutid").text(n.layoutid);
			   	
			       row.find(".klorder_num").text(n.order_num);
			   	
		 		   row.attr("id","ready"+i);
		           row.attr("class","tr_nbw");
		           row.appendTo("#"+frm+" .grid");
		       });   
			}
			
			var delplaceholders = function(){
				var options = {
				type: 'POST',
				async: false,
				dataType: 'content-type',
				success: function(msg) {
					alert("成功删除"+msg+"条记�?");
					document.location.reload();
				}
				}
				if(confirm('您确认要删除吗？')){
					document.getElementById("frm").action="<%=path%>/cms/placeholder/delplaceholders";
					$('#frm').ajaxSubmit(options);
				}
			}
			function addplaceholder(){
				$('<iframe src="<%=path %>/cms/placeholder/toForm/0" />').dialog({
	                title: 'placeholder属�??',
	                autoOpen: true,
	                width: 600,
	                height: 300,
	                modal: true,
		            buttons: {
						"保存": function() {
							if(this.contentWindow.save()=="success"){
								$( this ).dialog( "close" );
								alertMsg("保存成功�?");
								document.location.reload();
							}
						},
						"关闭": function() {
							$( this ).dialog( "close" );
						}
					}  
	            }).width(600).height(300);
			}
			
			function modifyplaceholder(id){
				if(checkOnlySel()){
					$('<iframe src="<%=path %>/cms/placeholder/toForm/'+getCheckedObj("chk")[0].value+'" />').dialog({
		                title: 'placeholder属�??',
		                autoOpen: true,
		                width: 600,
		                height: 300,
		                modal: true,
			            buttons: {
							"保存": function() {
								if(this.contentWindow.save()=="success"){
									$( this ).dialog( "close" );
									alertMsg("保存成功�?");
									document.location.reload();
								}
							},
							"关闭": function() {
								$( this ).dialog( "close" );
							}
						}  
		            }).width(600).height(300);
				}
			}
		</script>
	</head>
<body>
<form name="frm" method="post" style="margin: 0" action="<%=path%>/cms/placeholder/list" id="frm">
		<table width="100%">
			<tr>
				<td height="2px"></td>
			</tr>
			<tr><td align="right">
				<input type="button" onclick="addplaceholder();" class="button4_nbw" value="添加" />
				<input type="button" onclick="modifyplaceholder();" class="button4_nbw" value="修改" />
				<input type="button" onclick="delplaceholders()" class="button4_nbw" value="删除" />
				&nbsp;&nbsp;
				</td>
			</tr>
		</table>
		<center>
		<table><tr><td height="2px"></td></tr></table>
		<table border="0" cellspacing="1" cellpadding="0" class="table_nbw  niceTable grid">
			<thead class="th_nbw">
				<tr >
					<td width="40px" >
						<input type="checkbox" class="allCheck" />
					</td>
		      		<td>
						placeholderid
					</td>   
		      		<td>
						channelid
					</td>   
		      		<td>
						portletid
					</td>   
		      		<td>
						layoutid
					</td>   
		      		<td>
						order_num
					</td>   
					<td>
						操作
					</td>
				</tr>
			</thead>
			<tbody>
				<tr class="template klId">
					<td width="40px" class="idCheck">
						<input type="checkbox" name="chk" class="klId" />
					</td>
		   		    <td class="klplaceholderid niceTable-left"></td>
		   		    <td class="klchannelid niceTable-left"></td>
		   		    <td class="klportletid niceTable-left"></td>
		   		    <td class="kllayoutid niceTable-left"></td>
		   		    <td class="klorder_num niceTable-left"></td>
					 <td >
						<a href=""  class="klmodi"/>修改</a>&nbsp;
					 </td>
				</tr>
			</tbody>
			<tfoot>
				<tr>
					<td style="border-right: none">
						<img class="loading"
							src="/resources/skins/default/images/large-loading.gif" width="20px"
							class="hidden" />
					</td>
					<td colspan="4" style="border-left: none" class="txtRight">
						<span class="pagediv"></span>
					</td>
				</tr>
			</tfoot>
		</table>
		</center>
	</form>
</body>
</html>
